<?php

namespace app\api\model;

use think\Exception;
use think\model\concern\SoftDelete;

class LinUser extends BaseModel
{
    use SoftDelete;

    protected $deleteTime = 'delete_time';
    protected $autoWriteTimestamp = 'datetime';

    public static function getList(array $conditions){
        $query = new static();

        $keys = array_keys($conditions);
        try{
            if(!empty($keys)){
                foreach ($keys as $key){
                    if($key == "page") continue;
                    if($key == "username" && !empty($conditions[$key])){
                        $query = $query->where($key,"like","%".$conditions[$key]."%");
                        continue;
                    }
                    if(!empty($conditions[$key])) $query = $query->where($key,$conditions[$key]);

                }
            }

            return $query->paginate();
        }catch (Exception $e){
            throw new Exception(["msg" => "参数错误"]);
        }

    }

}